<?php
if($row_menu_one['parent_id']==0){
	$view_post = '<div id="product_catalog">';
	$cap1 = $tc->menu($row_menu_one['id']);
	while($row_cap1 = mysql_fetch_array($cap1)){
		$view_post .= '<h2>'.$row_cap1['name'].'</h2>';
		
		$list_sp = $tc->list_product($row_cap1['id'],7);
		while($row_list_sp = mysql_fetch_array($list_sp)){
			($row_list_sp['price']!=0) ? $price = number_format($row_list_sp['price']).'đ' : $price = 'Call';
			$view_post .= '<div class="item">
			<a href="'.$row_cap1['url'].$row_list_sp['name_rewrite'].'.html">
				<img src="'.url_product_thumb_image.$row_list_sp['url_hinh'].'" alt="'.$row_list_sp['name'].'" />
				<h3>'.$row_list_sp['name'].'</h3>
			</a>
			<p>Mã SP: '.$row_list_sp['masp'].'</p>
			<p>Giá: <font color="#CC0000">'.$price.'</font></p>
			</div>';
		}
		$view_post .= '<div style="clear:both; height:1px"></div>
		<div style="text-align:right; margin:0 20px 10px 0"><a href="'.$row_cap1['url'].'">Xem thêm..</a></div>';
	}
	$view_post .= '<div style="clear:both; height:1px"></div></div>';
}else{
	$from = (($page - 1) * max_product);
	$select = 'name,name_rewrite,url_hinh,masp,price';
	$table = 'product';
	$where = "`delete`=0 AND status=1 AND menu_id LIKE '%,".$row_menu_one['id'].",%'";
	$limit = "LIMIT {$from},".max_product;
	$list = $tc->list_item($select,$table,$where,$limit);
	
	$view_post = '<div id="product"><h1>'.$row_menu_one['title'].'</h1><h2>'.$row_menu_one['metaDescription'].'</h2>';
	while($row_list_sp = mysql_fetch_array($list)){
		($row_list_sp['price']!=0) ? $price = number_format($row_list_sp['price']).'đ' : $price = 'Call';
		$view_post .= '<div class="item"><a href="'.$row_menu_one['url'].$row_list_sp['name_rewrite'].'.html"><img src="'.url_product_thumb_image.$row_list_sp['url_hinh'].'" alt="'.$row_list_sp['name'].'" /><h4>'.$row_list_sp['name'].'</h4></a>
		<p>Mã SP: '.$row_list_sp['masp'].'</p>
		<p>Giá: <font color="#CC0000">'.$price.'</font></p></div>';
	}
	$phantrang = $tc->phantrang($row_menu_one['url'],$page,max_product,'id',$table,$where);
	$view_post .= "<div id=\"phantrang\">{$phantrang}</div>";
	$view_post .= '<div style="clear:both; height:1px"></div></div>';
}